import 'dart:convert';

import 'VideoEntity.dart';


class ClassifyBeanEntity {
  List<TypeList>? typeList;
  List<ListVideoElement>? articles;

  ClassifyBeanEntity({
    required this.typeList,
    required this.articles,
  });

  factory ClassifyBeanEntity.fromJson(Map<String, dynamic> json) => ClassifyBeanEntity(
    typeList: List<TypeList>.from(json["type_list"].map((x) => TypeList.fromJson(x))),
    articles: List<ListVideoElement>.from(json["articles"].map((x) => ListVideoElement.fromJson(x))),
  );
}

class Article {
  int? id;
  DateTime? createdAt;
  DateTime? updatedAt;
  String? articleClass;
  int? typeId;
  String? title;
  String? content;
  String? imgHead;
  int? status;
  int? viewNum;
  int? isTop;

  Article({
    required this.id,
    required this.createdAt,
    required this.updatedAt,
    required this.articleClass,
    required this.typeId,
    required this.title,
    required this.content,
    required this.imgHead,
    required this.status,
    required this.viewNum,
    required this.isTop,
  });

  factory Article.fromJson(Map<String, dynamic> json) => Article(
    id: json["id"],
    createdAt: DateTime.parse(json["created_at"]),
    updatedAt: DateTime.parse(json["updated_at"]),
    articleClass: json["class"],
    typeId: json["type_id"],
    title: json["title"],
    content: json["content"],
    imgHead: json["img_head"],
    status: json["status"],
    viewNum: json["view_num"],
    isTop: json["is_top"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "created_at": createdAt?.toIso8601String(),
    "updated_at": updatedAt?.toIso8601String(),
    "class": articleClass,
    "type_id": typeId,
    "title": title,
    "content": content,
    "img_head": imgHead,
    "status": status,
    "view_num": viewNum,
    "is_top": isTop,
  };
}

class TypeList {
  int? typeId;
  String? typeName;

  TypeList({
    required this.typeId,
    required this.typeName,
  });

  factory TypeList.fromJson(Map<String, dynamic> json) => TypeList(
    typeId: json["type_id"],
    typeName: json["type_name"],
  );

  Map<String, dynamic> toJson() => {
    "type_id": typeId,
    "type_name": typeName,
  };
}
